package hc.util
import org.apache.poi.xssf.usermodel.*;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.*;

@groovy.transform.CompileStatic
class ExcelUtil {

	public static ArrayList<ArrayList<String>> readExcelFixedWidth(String fileName, String anchor, int width) {
		Object table =ExcelReader.options()
				.withFile(fileName)
				.withAnchorAt(anchor)
				.withTableWidthFixed(width)	//*
				.enableTrimCellText()
				.enableNullCellFilledBlank()
				.build()
				.readTable();
	}

	public static ArrayList<ArrayList<String>> readExcelWidthReferingRow(String fileName, String anchor, int rowForWidth) {
		Object table =ExcelReader.options()
				.withFile(fileName)
				.withAnchorAt(anchor)
				.withTableWidthReferToRow(1) //*
				.enableTrimCellText()
				.enableNullCellFilledBlank()
				.build()
				.readTable();
	}



	public static ArrayList<ArrayList<String>> readExcel(String fileName, String anchor) {
		readExcelFixedWidth(fileName,anchor,0)
	}


	public static void main(String[] args) {

		def filename = 'src/hc/bre/dtable/decisiontableSimpleSample.xlsx'

		Object table =
				readExcelFixedWidth filename ,'决策表名称',5

		println table
	}
}
